/*
 * @(#)ODPEntry.java	0.1 04/02/06
 *
 * Copyright 2006 Fabio Gasparetti. All rights reserved.
 */

package org.tabularium.text.se.odp;

/**
 * An entry in the ODP data file.
 */
public class ODPEntry implements Comparable {
	public String id;	
	public String topic;
	public String catid; // not-used
	public String title; // not-used
	public String link;  // url
	public String pagetitle;
	public String pagedescription;

	public String toString() {
		return "id:" + id + "\ntopic:" + topic + "\ncatid:" + catid
				+ "\ntitle:'" + title + "\nlink:" + link + "\npagetitle:"
				+ pagetitle + "\npagedescription:" + pagedescription + "'";
	}

	public boolean equals(Object o) {
		return compareTo(o) == 0;
	}

	public int compareTo(Object o) {
		return id.compareTo(((ODPEntry) o).id);
	}

	/**
	 * Depth 0 corresponds to Top level.
	 */
	public int depth() {
		int j = 0, depth = 0;
		while ((j = topic.indexOf('/', j + 1)) > 0)
			depth++;
		return depth;
	}
}
